//
//  UIButton+ButtonStyle.m
//  propertyApp
//
//  Created by lshenrong on 17/3/27.
//  Copyright © 2017年 Mac-Mini-KingVision. All rights reserved.
//

#import "UIButton+ButtonStyle.h"
#import "YYCategories.h"

@implementation UIButton (ButtonStyle)

- (void)styleWithNormalColor:(UIColor *)normalColor highlightColor:(UIColor *)highlightColor{
    [self setBackgroundImage:[UIImage imageWithColor:normalColor] forState:UIControlStateNormal];
    [self setBackgroundImage:[UIImage imageWithColor:highlightColor] forState:UIControlStateHighlighted];
    [self setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"0xd3d3d3"]] forState:UIControlStateDisabled];
    [self whiteTextStyle];
}


//////////
- (void)loginStyle{
    [self setBackgroundImage:[UIImage imageWithColor:kMasterColor] forState:UIControlStateNormal];
    [self setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"0xeb8e34"]] forState:UIControlStateHighlighted];
    [self setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"0xd3d3d3"]] forState:UIControlStateDisabled];
    [self whiteTextStyle];
}


- (void)loginOrangeStyle{
    [self setBackgroundImage:[UIImage imageWithColor:kOrangeColor] forState:UIControlStateNormal];
    [self setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"0xeb8e34"]] forState:UIControlStateHighlighted];
    [self setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"0xd3d3d3"]] forState:UIControlStateDisabled];
   [self whiteTextStyle];
}


- (void)registerStyle{
    [self setBackgroundImage:[UIImage imageWithColor:kRegisterColor] forState:UIControlStateNormal];
    [self setBackgroundImage:[UIImage imageWithColor:kRegisterHighlightColor] forState:UIControlStateHighlighted];
    [self setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"0xd3d3d3"]] forState:UIControlStateDisabled];
   [self whiteTextStyle];
}



- (void)borderColorStyle{
    UIColor *color = kMasterColor;
    [self.layer setBorderColor:color.CGColor];
    [self.layer setBorderWidth:1.0f];
    [self setBackgroundColor:[UIColor whiteColor]];
}

- (void)borderStyleWithColor:(UIColor *)color cornerRadius:(CGFloat)radius{
    [self.layer setBorderColor:color.CGColor];
    [self.layer setBorderWidth:0.5f];
    [self setBackgroundColor:[UIColor whiteColor]];
    self.layer.cornerRadius = radius;
    self.layer.masksToBounds = YES;
}

- (void)cornerRadiusStyle:(CGFloat)radius{
    self.layer.cornerRadius = radius;
    self.layer.masksToBounds = YES;
}

#pragma mark - 验证码

- (void)phoneVerificationCodeStyle{
    [self setTitleColor:kMasterColor forState:UIControlStateNormal];
    [self setTitleColor:kGrayTextColor forState:UIControlStateHighlighted];
    [self setTitleColor:kGrayColor forState:UIControlStateDisabled];
    [self PFCGStyleFontSize:14.0];
}

- (void)buyDefaultStyle{
     [self PFCGStyleFontSize:18.0];
    [self cornerRadiusStyle:5];
}


- (void)updateButtonTitle:(NSString *)title{
   // self.titleLabel.text = title;
    [self setTitle:title forState:UIControlStateNormal];// 添加文字
}

- (void)updateButtonImage:(NSString *)image{
    [self setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
}

- (void)fontColorStyle:(UIColor *)color{
     [self setTitleColor:color forState:UIControlStateNormal];
}



- (void)setBuyDisabledStyle:(BOOL)isDisabled{
    if(isDisabled){
        [self setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"0xd3d3d3"]] forState:UIControlStateHighlighted];
        [self setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"0xd3d3d3"]] forState:UIControlStateNormal];
          [self setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"0xd3d3d3"]] forState:UIControlStateDisabled];
    }else{
        [self setBackgroundImage:[UIImage imageWithColor:kOrangeColor] forState:UIControlStateNormal];
        [self setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"0xeb8e34"]] forState:UIControlStateHighlighted];
        [self setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"0xd3d3d3"]] forState:UIControlStateDisabled];
    }
}

- (void)whiteTextStyle{
    [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self setTitleColor:[UIColor whiteColor] forState:UIControlStateDisabled];
    [self setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
}

#pragma mark - PingFangSC-Regular 平方常规

- (void)PFCGStyleFontSize:(CGFloat)fontSize{
    self.titleLabel.font = PingFangZhongChangGuiForFont(fontSize);
}

- (void)PFCGStyleTextColor:(UIColor *)color fontSize:(CGFloat)size{
    [self setTitleColor:color forState:UIControlStateNormal];
    [self PFCGStyleFontSize:size];
}

@end
